<template>
	<view class="mine-container" :style="{height: `${windowHeight}px`}">
		<!--顶部个人信息栏-->
		<view class="header-section">
			<view class="flex justify-between">
				<view class="flex align-center">
					<view v-if="!avatar" class="cu-avatar xl round bg-white">
						<view class="iconfont icon-people text-gray icon"></view>
					</view>
					<image v-if="avatar" @click="handleToAvatar" :src="avatar" class="cu-avatar xl round"
						mode="widthFix">
					</image>
					<view v-if="!name" @click="handleToLogin" class="login-tip">
						点击登录
					</view>
					<view v-if="name" @click="handleToInfo" class="user-info">
						<view class="u_title">
							{{realName}}
						</view>
						<view class="u_title_n">
							{{phoneNo}}
						</view>
					</view>
				</view>
				<view class="flex align-center handle-to">
					<text class="textone">一级巡视员</text>
					<!-- <view class="iconfont icon-right"></view> -->
				</view>
			</view>
		</view>

		<view class="buttom-ks">
			<view>
				<image src="@/static/txl.png" @click="getInfoBook()" />
			</view>
			<view class="vac">
				<text class="textone">{{myData.enterpriseNum}}</text>家
				<br />
				<text class="textone">{{myData.minePersonNum}}</text>人
			</view>
		</view>
		<view class="content-section">
			<view class="menu-list">
				<view class="list-cell list-cell-arrow list-vcell" @click="handleToEditInfo">
					<view class="menu-item-box">
						<view class="v-top"></view>
						<view class="v-buttom">双预防管理</view>
						<view class="v-fb">共{{myData.pointNum}}个风险点</view>
					</view>
				</view>
				<view class="list-cell list-cell-arrow list-vcell" @click="handleHelp">
					<view class="menu-item-box">
						<view class="v-top"></view>
						<view class="v-buttom">企业档案</view>
						<view class="v-fb">共{{myData.enterpriseNum}}家企业</view>
					</view>
				</view>
				<view class="list-cell list-cell-arrow list-vcell" @click="handleAbout(userId)">
					<view class="menu-item-box">
						<view class="v-top"></view>
						<view class="v-buttom">我的发布</view>
						<view class=" v-fb">共{{myData.knowledgeBaseNum}}篇</view>
					</view>
				</view>
				<view class="list-cell list-cell-arrow list-vcell" @click="handleToSettingSS">
					<view class="menu-item-box">
						<view class="v-top"></view>
						<view class="v-buttom">矿山专家</view>
						<view class="v-fb">共{{myData.expertNum}}名专家</view>
					</view>
				</view>
				<view class="list-cell list-cell-arrow list-vcell" @click="handleToSetting">
					<view class="menu-item-box">
						<view class="v-top"></view>
						<view class="v-buttom">矿山事故</view>
						<view class="v-fb">共{{myData.accidentNum}}起事故</view>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import storage from '@/utils/storage'
	import {
		myList
	} from "@/api/my/my.js"
	export default {
		data() {
			return {
				myData: {},
				name: "刘德华",
				// name: this.$store.state.user.name,
				version: getApp().globalData.config.appInfo.version
			}
		},
		//注意函数和data同级,不要写在methods内	
		onNavigationBarButtonTap(e) {
			if (e.index == 0) {
				this.$tab.navigateTo('/pages/my/setting/index')

			};
			if (e.index == 1) {
				this.$tab.navigateTo('/pages/my/systemmessage/index')

			}
		},

		computed: {
			avatar() {
				return this.$store.state.user.avatar
			},
			windowHeight() {
				return uni.getSystemInfoSync().windowHeight - 50
			},
			phoneNo() {
				return this.$store.state.user.dataList.phoneNo
			},

			realName() {
				return this.$store.state.user.dataList.realName
			},
			userId() {
				return this.$store.state.user.dataList.userId
			}
		},
		mounted() {
			this.getMyList()
		},
		methods: {
			handleToInfo() {
				this.$tab.navigateTo('/pages/mine/info/index')
			},
			handleToEditInfo() {
				this.$tab.navigateTo('/pages/my/warning/index')
			},
			handleToSetting() {
				this.$tab.navigateTo('/pages/my/accidentfile/index')
			},
			handleToLogin() {
				this.$tab.reLaunch('/pages/login')
			},
			handleToAvatar() {
				this.$tab.navigateTo('/pages/mine/avatar/index')
			},
			handleLogout() {
				this.$modal.confirm('确定注销并退出系统吗？').then(() => {
					this.$store.dispatch('LogOut').then(() => {
						this.$tab.reLaunch('/pages/index')
					})
				})
			},
			getInfoBook() {
				this.$tab.navigateTo('/pages/my/addressbook/index')
			},
			handleAbout(userId) {
				this.$tab.navigateTo(`/pages/my/myrelease/index?id=${userId}`)
			},
			handleHelp() {
				this.$tab.navigateTo('/pages/my/enterprisefiles/index')
			},
			handleToSettingSS() {
				this.$tab.navigateTo('/pages/my/archivesexperts/index')
			},

			// 我的数据
			getMyList() {
				myList().then((result) => {
					this.myData = result.data
				}).catch((err) => {
					console.log(err)
				})
			}
		}
	}
</script>

<style lang="scss">
	page {
		background-color: #f5f6f7;
	}

	.mine-container {
		width: 100%;
		height: 100%;
		padding: 10px 10px 45px 10px;


		.header-section {
			padding: 22px 0px 22px 15px;
			background-color: #FFF;
			color: #000;
			border-radius: 4px 4px 0px 0px;

			.login-tip {
				font-size: 18px;
				margin-left: 10px;
			}

			.cu-avatar {
				border: 2px solid #eaeaea;

				.icon {
					font-size: 40px;
				}
			}

			.user-info {
				margin-left: 15px;

				.u_title {
					font-size: 20px;
					font-family: PingFangSC-Semibold, PingFang SC;
					font-weight: 600;
					color: #343434;
					line-height: 62rpx;

				}

				.u_title_n {
					font-size: 16px;
					font-family: PingFangSC-Regular, PingFang SC;
					font-weight: 400;
					color: #595959;
					line-height: 22px;
				}
			}
		}

		.content-section {
			position: relative;

			.mine-actions {
				margin: 15px 15px;
				padding: 20px 0px;
				border-radius: 8px;
				background-color: white;

				.action-item {
					.icon {
						font-size: 28px;
					}

					.text {
						display: block;
						font-size: 13px;
						margin: 8px 0px;
					}
				}
			}
		}
	}

	.handle-to {
		width: 108px;
		height: 36px;
		position: absolute;
		right: 0;
		background-color: #123;
		background: linear-gradient(to right, #2A62A5, #5192DF);
		border: 1px solid #004CA7;
		border-right: none;
		border-radius: 20px 0px 0px 20px;
		margin-top: 36rpx;

		.textone {
			color: #fff;
			margin-left: 30rpx;
		}
	}

	.buttom-ks {
		height: 78px;
		background-color: #123;
		background: linear-gradient(to right, #e4eaf0, #e4eaf0);
		border-radius: 5px;
		display: flex;
		justify-content: space-evenly;
		align-items: center;
		border: 1px solid #B0D4FF;

		image {
			width: 440rpx;
			height: 52rpx;
		}

		text {
			font-size: 20px;
			font-family: Roboto-BoldItalic, Roboto;
			font-weight: normal;
			color: #225EA4;
			line-height: 24px;
			font-weight: 700
		}
	}

	.vac {
		font-size: 14px;
		color: #225EA4;
		font-style: italic;
	}

	.menu-list {
		margin: 10px 0rpx 0rpx 0rpx;
	}

	.list-cell:first-child {
		border-radius: 4px 4px 4px 4px;
	}

	.list-cell {
		padding: 21px 16px;
	}

	.v-top {
		width: 10px;
		height: 18px;
		background-color: #123;
		border-radius: 0px 50px 50px 0px;
		margin-left: -15px;
		background: #9EBADB
	}

	.v-buttom {
		width: 90px;
		height: 25px;
		font-size: 18px;
		font-family: PingFangSC-Medium, PingFang SC;
		font-weight: 700;
		color: rgba(52, 52, 52, 0.85);
		line-height: 25px;
		text-align: left;
		margin-left: 15px;
	}

	.v-fb {
		font-size: 14px;
		font-family: PingFangSC-Regular, PingFang SC;
		font-weight: 400;
		color: #8C8C8C;
		line-height: 24px;
		position: absolute;
		right: 28px;
		width: 154px;
		text-align: right;
	}

	.list-vcell {
		margin-bottom: 10px;
		background: #FFFFFF;
		box-shadow: 0px 4px 6px 0px rgba(123, 149, 149, 0.08);
		border-radius: 4px;
	}
</style>
